<?php
	namespace Qzn\Controller;
	require_once('./Model/wallHandler.php');
	require_once('./View/wallView.php');
	require_once('./Model/validate.php');
	
	class WallController {
		
		/**
		 * @param LoginView $lw
		 * @param Database $db
		 * @param LoginHandler $lh
		 * @return string $html
		 */
		public function DoControll(\Qzn\Model\Database $db, \Qzn\View\LoginView $lw, \Qzn\Model\LoginHandler $lh, \Qzn\Model\ProfileHandler $ph) {
			$ww = new \Qzn\View\WallView();
			$v = new \Qzn\Model\Validate();
			$wh = new \Qzn\Model\WallHandler($db, $v);
			$html = "";
			
			if ($lh->IsLoggedIn()) {
				if ($ww->TriedToPost()) {
					$html .= $wh->SendPost($ww, $lw);
				}
				
				if ($ww->TriedToComment()) {
					$html .= $wh->SendComment($ww, $lw);
				}
				
				if ($ww->TriedToMessageLike()) {
					$html .= $wh->SendMessageLike($ww, $lw);
				}
				
				if ($ww->TriedToMessageDislike()) {
					$html .= $wh->SendMessageDislike($ww, $lw);
				}
				
				if ($ww->TriedToCommentLike()) {
					$html .= $wh->SendCommentLike($ww, $lw);
				}
				
				if ($ww->TriedToCommentDislike()) {
					$html .= $wh->SendCommentDislike($ww, $lw);
				}
				
				if (\Qzn\View\NavigationView::IsViewingMessage()) {
					$html .= $ww->DoMessageBox($wh->GetMessage(\Qzn\View\NavigationView::GetMessagePk(), $wh), $wh, $lw, $ph, $v);
				} else {
					$html .= $ww->DoWallBox($wh, $lw, $ph, $v);
				}
			}
			
			return $html;
		}
	}
?>